package com.fanshuai2.niuke.strings;

import java.util.*;

public class NumString {
    static String numString(String s) {
        List<String> nums = new ArrayList<>();

        boolean digitFlag = false;
        int k = 0;
        for (int i = 0; i < s.length(); i++) {
            char ch = s.charAt(i);
            if (Character.isDigit(ch)) {
                if (!digitFlag) {
                    k = i;
                }
                digitFlag = true;
                if (i == s.length() - 1) {
                    String t = s.substring(k, i + 1);
                    nums.add(t);
                }
            } else {
                if (digitFlag) {
                    String t = s.substring(k, i);
                    nums.add(t);
                }
                digitFlag = false;
            }
        }
        nums.sort((s1, s2) -> {
            return s2.length() - s1.length();
        });

        int maxLen = nums.get(0).length();
        StringBuilder b = new StringBuilder();
        for (String num: nums) {
            if (num.length() == maxLen) {
                b.append(num);
            } else {
                break;
            }
        }
        b.append(",").append(maxLen);
        return b.toString();
    }
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        // 注意 hasNext 和 hasNextLine 的区别
        while (in.hasNextLine()) { // 注意 while 处理多个 case
            String s = in.nextLine();
            System.out.println(numString(s));
        }
    }
}
